package com.lianziyou.chain.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.web3j.protocol.Web3jService;
import org.web3j.protocol.core.JsonRpc2_0Web3j;
import org.web3j.protocol.http.HttpService;

import java.util.concurrent.ScheduledExecutorService;

/**
 * 配置一个bsc链的web3j对象
 */
@Configuration
public class BscWeb3jConfig {

    @Bean
    public BscWeb3j bscWeb3j(){
//        return new BscWeb3j(new HttpService("https://bsc-dataseed4.ninicoin.io/")); //主网
        return new BscWeb3j(new HttpService("https://data-seed-prebsc-1-s1.binance.org:8545/")); //测试网
    }

    public class BscWeb3j extends JsonRpc2_0Web3j {

        public BscWeb3j(Web3jService web3jService) {
            super(web3jService);
        }

        public BscWeb3j(Web3jService web3jService, long pollingInterval, ScheduledExecutorService scheduledExecutorService) {
            super(web3jService, pollingInterval, scheduledExecutorService);
        }
    }
}
